public class deadLock {
    static Object a = new Object();
    static Object b = new Object();
    // jps jstack 可以找到死锁
    public static void main(String[] args) {
        new Thread(()->{
            synchronized(a){
                System.out.println(Thread.currentThread().getName()+" 持有a，获取b");
                synchronized(b){
                    System.out.println(Thread.currentThread().getName()+" 获取到 b ...");
                }
            }
        },"T1").start();
        new Thread(()->{
            synchronized(b){
                System.out.println(Thread.currentThread().getName()+" 持有b，获取a");
                synchronized(a){
                    System.out.println(Thread.currentThread().getName()+" 获取到 a ...");
                }
            }
        },"T2").start();;
    }
}
